package com.sccomsumer.comsumer.Hystrix;

import com.sccomsumer.comsumer.service.UserCommonHystrixService;
import feign.FeignException;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class UserProviderBackFactory implements FallbackFactory<UserCommonHystrixService> {
    @Override
    public UserCommonHystrixService create(Throwable cause) {
        return new UserCommonHystrixService() {


            @Override
            public String testHystrix() {
                if (cause instanceof FeignException.InternalServerError) {

                    return "远程服务器 500" + cause.getLocalizedMessage();
                } else {

                    return "呵呵";
                }
            }
        };
    }
}
